=========================================================================== BBS: The Abacus * HST/DS * Potterville, MI Date: 06-08-93 (03:03) Number: 201 From: RICH GELDREICH Refer#: NONE To: CALVIN FRENCH Recvd: NO Subj: Gif Loader/1 Conf: (35) Quick Basi --------------------------------------------------------------------------- 9Ô_Ê'______O_/__________________| SNIP |__________________\_O______ ' O \ | HERE | / O 'This file created by PostIt! v6.1. '>>> Start of page 1. ' 'DEGIF6.BAS - No frills GIF decoder for the VGA's 320x200x256 mode. 'By Rich Geldreich 1993 (Public domain, use as you wish.) 'This version should properly decode all LZW encoded images in 'GIF image files. I've finally added GIF89a and local colormap 'support, so it more closely follows the GIF specification. It 'still doesn't support the entire GIF89a specification, but it'll 'show most GIF files fine. 'The GIF decoding speed of this program isn't great, but I'd say 'for an all QB/PDS decoder it's not bad! 'Note: This program does not stop decoding the GIF image after the 'rest of the scanlines become invisible! This happens with images 'larger than the 320x200 screen. So if the program seems to be 'just sitting there, accessing your hard disk, don't worry... 'It'll beep when it's done. DEFINT A-Z 'Prefix() and Suffix() hold the LZW phrase dictionary. 'OutStack() is used as a decoding stack. 'ShiftOut() as a power of two table used to quickly retrieve the LZW 'multibit codes. DIM Prefix(4095), Suffix(4095), OutStack(4095), ShiftOut(8) 'The following line is for the QB environment(slow). DIM YBase AS LONG, Powersof2(11) AS LONG, WorkCode AS LONG 'For a little more speed, unremark the next line and remark the one 'above, before you compile... You'll get an overflow error if the 'following line is used in the QB environment, so change it back. 'DIM YBase AS INTEGER, Powersof2(11) AS INTEGER, WorkCode AS INTEGER 'Precalculate power of two tables for fast shifts. FOR A = 0 TO 8: ShiftOut(8 - A) = 2 ^ A: NEXT FOR A = 0 TO 11: Powersof2(A) = 2 ^ A: NEXT 'Get GIF filename. A$ = COMMAND$: IF A$ = "" THEN INPUT "GIF file"; A$: IF A$ = ""_ THEN END 'Add GIF extension if the given filename doesn't have one. FOR A = LEN(A$) TO 1 STEP -1 SELECT CASE MID$(A$, A, 1) CASE "\", ":": EXIT FOR CASE ".": Extension = -1: EXIT FOR END SELECT NEXT IF Extension = 0 THEN A$ = A$ + ".GIF" 'Open file for input so QB stops with an error if it doesn't exist. OPEN A$ FOR INPUT AS #1: CLOSE #1 OPEN A$ FOR BINARY AS #1 'Check to see if GIF file. Ignore GIF version number. A$ = " ": GET #1, , A$ IF LEFT$(A$, 3) <> "GIF" THEN PRINT "Not a GIF file.": END 'Get logical screen's X and Y resolution. GET #1, , TotalX: GET #1, , TotalY: GOSUB GetByte 'Calculate number of colors and find out if a global palette exists. NumColors = 2 ^ ((A AND 7) + 1): NoPalette = (A AND 128) = 0 'Retrieve background color. GOSUB GetByte: Background = A 'Get aspect ratio and ignore it. GOSUB GetByte 'Retrieve global palette if it exists. IF NoPalette = 0 THEN P$ = SPACE$(NumColors * 3): GET #1, , P$ DO 'Image decode loop 'Skip by any GIF extensions. '(With a few modifications this code could also fetch comments.) DO 'Skip by any zeros at end of image (why must I do this? the 'GIF spec never mentioned it) DO IF EOF(1) THEN EXIT DO 'if at end of file, exit GOSUB GetByte '>>> Continued on page 2 --- MsgToss 2.0b * Origin: Computer Co-Op - Voorhees, NJ | Ted Hare (1:266/29) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/110 159/100 125 430 575 950 203/23 209/209 SEEN-BY: 261/1023 280/1 390/1 396/1 15 397/2 2230/100 2440/5 3603/20